//
//  PositionGroupTableViewCell.m
//  mcrmSAAS
//
//  Created by wjxfhxy on 15-3-11.
//  Copyright (c) 2015年 GuangZhouXuanWu. All rights reserved.
//

#import "PositionGroupTableViewCell.h"

#pragma mark --
#pragma mark -- positionGroupTableViewCell

@interface PositionGroupTableViewCell ()<XUIButtonDelegate>
{
    XUIButton *_positionBtn;
}
@end

@implementation PositionGroupTableViewCell

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    _positionBtn = [XUIButton buttonWithStyleType:XUIButtonStyleTypeCenterImage delegate:self];
    _positionBtn.size = CGSizeMake(40, 40);
    [_positionBtn SetImage:[UIImage imageNamed:@"img_location.png"]];
    [self.contentView addSubview:_positionBtn];
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _positionBtn.right = self.contentView.width/* - 10*/;
    _positionBtn.centerY = self.contentView.height/2;
    
    _textField.width = self.contentView.width - _textField.left - _positionBtn.width/* - 10 - 10*/;
}

-(void)clickedUpInsideOfButton:(XUIButton *)btn
{
    if([(id<PositionGroupTableViewCellDelegate>)self.delegate respondsToSelector:@selector(positionGroupTableViewCell:didClick:)])
        [(id<PositionGroupTableViewCellDelegate>)self.delegate positionGroupTableViewCell:self didClick:nil];
}

+(CGFloat)caleHeight
{
    return 40;
}

@end

@implementation PositionStaticTextGroupTableViewCell
{
    UIImageView *_arrowImageView;
}

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    _arrowImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"img_location.png"]];
    [self.contentView addSubview:_arrowImageView];
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _arrowImageView.right = self.width - 10;
    _arrowImageView.centerY = self.height/2;
}

+(CGFloat)textMaxContainWidth:(CGFloat)containWidth
{
    return [StaticTextGroupTableViewCell textMaxContainWidth:containWidth] -  [UIImage imageNamed:@"img_location.png"].size.width - 10;
}
@end
